<template>
	<view style="background: #FFFFFF;">
		<scroll-view style="height: 1350rpx;width: 750rpx;box-sizing: border-box;" scroll-y="true" refresher-enabled="true" :refresher-triggered="triggered"
			:refresher-threshold="0" refresher-background="#EE7B30" @refresherpulling="onPulling" @refresherrefresh="onRefresh" :scroll-top="scrollTop"  @scrolltolower="scrolltolower">
			<view class="kecheng" style="margin: 20rpx 0 0 30rpx;width: 690rpx;background: #FFFFFF;box-sizing: border-box;">
				<view v-for="(itme,index) in jigou_ke" :key="index" @tap="gokechengxiang(itme)">
					<view style="display: flex;" class="box_wai">
						<view class="img">
							<image :src="itme.face_url" class="img"></image>
							<view class="categories_child">{{itme.label}}</view>
							<view class="vertical" v-if="itme.is_attend_activities">
								<image :src="quan_" mode="widthFix" style="width: 170rpx;vertical-align: bottom;"></image>
							</view>
						</view>
						<view style="margin-left: 20rpx;">
							<view style="font-size: 29rpx;font-weight: bold;">{{itme.itt}}</view>
							<view style="display: flex;justify-content: space-between;align-items: center;height: 37rpx;margin:20rpx 0;">
								<view style="display: flex;align-items: center;position: relative;">
									<view style="color: #FF3D3D;font-weight:bold ;">
										<text style="font-size:20rpx;">￥</text>
										<text style="font-size:33rpx;margin: 0 5rpx;">{{itme.original_price}}</text>
										<text style="font-size:20rpx;">/节</text>
									</view>
									<!-- <view style="font-weight:bold ;height: 37rpx;font-size: 25rpx;text-decoration: line-through;color: #D6D6D6;position: relative;top: 10rpx;left: 10rpx;">
										<text style="font-size:20rpx;">￥</text>
										<text style="margin: 0 5rpx;">{{itme.original_price}}</text>
									</view> -->
								</view>
							</view>
							<view style="display: flex;justify-content: space-between;width: 500rpx;align-items: center;">
								<view style="display: flex;">
									<view v-if="itme.danjie_shifou != ''">
										<image :src="danjie_zhifu" class="img_huo"></image>
									</view>
									<view style="margin-left: 10rpx;" v-if="itme.pingtuan_shifou != ''">
										<image :src="pingtuan_img" class="img_huo"></image>
									</view>
									<view v-if="itme.xianshi_shifou != ''" style="margin-left: 10rpx;">
										<image :src="xianshi_img" class="img_huo"></image>
									</view>
								</view>
								<view style="font-size: 25rpx;color: #AEAEAE;">已售{{itme.pay_num}}</view>
							</view>
						</view>
					</view>
					<view style="height: 2rpx;width: 680rpx;background: #F5F5F5;margin: 30rpx 0;"></view>
				</view>
			</view>
			<view v-if="!isshow" style="display: flex;height: 60rpx;width: 750rpx;justify-content: center;align-items: center;">
				<view>
					<van-loading type="spinner" color="#323233" size="25"/>
				</view>
				<view style="color: #323233;margin-left: 10rpx;font-size: 30rpx;">努力加载中...</view>
			</view>
			<view style="height: 100rpx;width: 100%;margin: 30rpx 0;font-size: 25rpx;text-align: center;line-height: 100rpx;" v-if="isshow">
				暂无数据
			</view>
		</scroll-view>
		
	</view>
</template>
<script>
	export default {
		data(){
			return {
				danjie_zhifu: "http://img.curiousmore.com/77010182660",
				jigou_ke: [],
				num: 1,
				triggered: false,
				biao_num: 1,
				shua: 1,
				quan: {},
				isshow: null,
				quan_: "http://img.curiousmore.com/65584",
				danjie_img: "http://img.curiousmore.com/450973",
				pingtuan_img: "http://img.curiousmore.com/172161",
				xianshi_img: "http://img.curiousmore.com/307599"
			}
		},
		methods:{
		async	xin(){
			    let _this = this
				const res = await _this.$myRequest({
					url:"/masterSetPrice/queryNearByCourse",
					data:{
						pageSize:10,
						currentPage: _this.num,
						latitude: _this.weidu,
						longitude: _this.jingdu,
						status: 2,
						type: "mechanism_offline"
					},
				})
				res.data.forEach((itme) => {
					itme.itt = "【" + itme.course_num + "节" + "￥" + itme.default_discount_price + "】" + itme.title
					itme.danjie_shifou = ""
					itme.xianshi_shifou = ""
					itme.pingtuan_shifou = ""
					if(itme.map.activityEntityList != null && itme.map.activityEntityList.length != 0){
						itme.map.activityEntityList.forEach((itmes) => {
							if(itmes.type == "single_payment"){
								itme.danjie_shifou = true
							}else if(itmes.type == "salesCourse"){
								itme.xianshi_shifou = true
							}else if(itmes.type == "grouping"){
								itme.pingtuan_shifou = true
							}
						})
					}
				})
				if(res.data.length < 10){
					_this.biao_num = 2
					uni.showToast({
						title: "无数据"
					})
				}else{
					_this.biao_num = 1
				}
				if(_this.jigou_ke.length == 0){
					_this.jigou_ke = res.data
				}else{
					_this.jigou_ke = _this.jigou_ke.concat(res.data)
				}
				_this.triggered = false
			},
			gokechengxiang(itme){
				uni.navigateTo({
				    url: '/pages/World/classChannel/classChannel?curriculumId=' + itme.id
				})
			},
			onRefresh(){
				this.isshow = false
				this.num = 1
				this.triggered = true
				this.jigou_ke = []
				this.xin()
			},
			scrolltolower(){
				if(this.biao_num == 1){
					this.num++
					this.xin()
				}else{
					this.isshow = true
					uni.showToast({
						title: "加载完毕",
						duration: 2000,
						icon: "none"
					})
				}
			}
		},
		onLoad() {
			this.jigou_ke = []
			try{
				const val = uni.getStorageSync('storage_key')
				if(uni.getStorageSync('kaquan')){
					this.quan = uni.getStorageSync('kaquan')
				}
				this.weidu = val.latitude
				this.jingdu = val.longitude
				this.xin()
			}catch(e){}
		},
		onShow() {
			
		}
	}
</script>
<style lang="scss" scoped>
	.panduan{
		color: #BFBFBF;
		text-decoration:line-through ;
		margin-left: 10rpx;
		font-size: 25rpx;
		margin-top: 15rpx;
	}
	.zhengchang{
		color:#FF3D3D;
		font-size: 30rpx;
	}
	.box_wai{
		display: flex;
		.img_huo{
			height: 40rpx;
			width: 130rpx;
		}
		.img{
			width: 170rpx;
			height: 170rpx;
			border-radius: 20rpx;
			position: relative;
			.categories_child{
				min-width: 50rpx;
				height: 38rpx;
				line-height: 38rpx;
				padding: 0 15rpx;
				font-size: 22rpx;
				background: #FF3D3D;
				text-align: center;
				border-radius: 20rpx 0 20rpx 0;
				position: absolute;
				top: 0;
				left: 0;
				color: #FFFFFF;
			}
			.vertical{
				position: absolute;
				left: 0;
				bottom: 0;
			}
		}
	}
</style>